from django.urls import path
from rest_framework.routers import DefaultRouter

from apps.meiduo_admin.views import login, home, users, images, sku, permission, group, admin, orders, spu, specs, \
    option

urlpatterns = [
    # 登录
    path('authorizations/', login.admin_obtain_jwt_token),

    # 获取日活跃量
    path('statistical/day_active/', home.DailyActiveCountView.as_view()),

    # 日下单用户量统计
    path('statistical/day_orders/', home.DailyOrderCountView.as_view()),

    # 月增用户统计
    path('statistical/month_increment/', home.MonthAddCountView.as_view()),

    # 用户总量统计
    path('statistical/total_count/', home.UserCountView.as_view()),

    # 日增用户统计
    path('statistical/day_increment/', home.DayIncrementCountView.as_view()),

    # 查询用户
    path('users/', users.UserListView.as_view()),

    # 获取sku列表数据
    path('skus/simple/', images.SKUListView.as_view()),

    # 获取三级分类数据
    path('skus/categories/', sku.CategoryAPIView.as_view()),

    # 获取spu数据
    path('goods/simple/', sku.SPUSimpleAPIView.as_view()),

    # 获取spu数据
    path('goods/<int:pk>/specs/', sku.SPUSpecAPIView.as_view()),

    # 获取权限类型列表数据
    path('permission/content_types/', permission.ContentTypeAPIView.as_view()),

    #获取所有权限
    path('permission/simple/',group.AllPermissionListAPIView.as_view()),

    #获取所有权限
    path('permission/groups/simple/',admin.UserGroupView.as_view()),

    #更新订单状态
    path('orders/<int:pk>/status/',orders.OrderStatusAPIView.as_view()),

    #获取品牌信息
    path('goods/brands/simple/', spu.BrandAPIView.as_view()),

    #获取一级分类数据
    path('goods/channel/categories/',spu.ChannelAPIView.as_view()),

    #获取二级和三级分类数据
    path('goods/channel/categories/<int:pk>/',spu.CateChannelAPIView.as_view()),

    # 获取规格信息
    path('goods/specs/simple/', option.OptionSimple.as_view()),
]

"""
1,创建路由
2,注册路由
3,将router自动生成的路由追加到urlpatterns中
"""
router = DefaultRouter()
router.register(r'skus/images', images.ImageAPIView, basename='image')
urlpatterns += router.urls

router.register(r'skus', sku.SKUModelView,basename='sku')
urlpatterns += router.urls

router.register(r'permission/perms', permission.PermissionModelView,basename='perms')
urlpatterns += router.urls

router.register(r'permission/groups',group.GroupModelView,basename='groups')
urlpatterns += router.urls

router.register(r'permission/admins',admin.AdminModelView,basename='admins')
urlpatterns += router.urls

router.register(r'orders',orders.OrdersAPIView,basename='orders')
urlpatterns += router.urls

router.register(r'goods', spu.SPUAPIView,basename='goods')
urlpatterns += router.urls

router.register(r'goods/specs', specs.SpecsView, basename='spu')
urlpatterns += router.urls

router.register(r'specs/options', option.OptionAPIView, basename='spu')
urlpatterns += router.urls